/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.faare.unittests;

import java.util.ArrayList;


/**
 * This class contains the description of the method tests results.
 */
public class TestMethod
{
    /** Name of the method. */
    private String methodName;

    /** List of errors. */
    private ArrayList errorsList;

    /** List of failures. */
    private ArrayList failsList;

    /** List of success. */
    private ArrayList successList;

    /** Number of tests. */
    private int testsNb;

    /**
     * Constructor of the class.
     */
    public TestMethod()
    {
        errorsList = new ArrayList();
        failsList = new ArrayList();
        successList = new ArrayList();

        testsNb = 0;
    }

    /**
     * Constructor with class name.
     *
     * @param name The name to set.
     */
    public TestMethod(String name)
    {
        this();
        setMethodName(name);
    }

    /**
     * Defines the name of the method.
     *
     * @param name  The name to set.
     */
    public void setMethodName(String name)
    {
        methodName = name;
    }

    /**
     * Adds an error.
     *
     * @param error  The error message.
     */
    public void addErrors(String error)
    {
        errorsList.add(error);
        testsNb++;
    }

    /**
     * Adds a failure.
     *
     * @param fail The failure message.
     */
    public void addFails(String fail)
    {
        failsList.add(fail);
        testsNb++;
    }

    /**
     * Adds a success.
     *
     * @param success  The success message.
     */
    public void addSuccess(String success)
    {
        successList.add(success);
        testsNb++;
    }

    /**
     * Gets the errors list.
     *
     * @return The list of errors.
     */
    public ArrayList getErrors()
    {
        return errorsList;
    }

    /**
     * Gets the failures list.
     *
     * @return The list of failures.
     */
    public ArrayList getFailures()
    {
        return failsList;
    }

    /**
     * Gets the success list.
     *
     * @return The list of success.
     */
    public ArrayList getSuccess()
    {
        return successList;
    }

    /**
     * Gets the number of tests for the method.
     *
     * @return The tests number.
     */
    public int getTestsNumber()
    {
        return testsNb;
    }

    /**
     * Gets the number of tests in error for the method.
     *
     * @return The tests number.
     */
    public int getErrorTestsNumber()
    {
        return errorsList.size();
    }

    /**
     * Gets the number of tests in failure for the method.
     *
     * @return The tests number.
     */
    public int getFailureTestsNumber()
    {
        return failsList.size();
    }

    /**
     * Gets the number of successfull tests for the method.
     *
     * @return The tests number.
     */
    public int getSuccessTestsNumber()
    {
        return successList.size();
    }

    /**
     * Gets the name of the method.
     *
     * @return The name.
     */
    public String getMethodName()
    {
        return methodName;
    }

    /**
     * Indicates if the method tests contain errors.
     *
     * @return true if the method tests contain error, false otherwise.
     */
    public boolean hasMethodErrors()
    {
        return !errorsList.isEmpty();
    }

    /**
     * Indicates if the method tests contain failures.
     *
     * @return true if the method tests contain failure, false otherwise.
     */
    public boolean hasMethodFailures()
    {
        return !failsList.isEmpty();
    }

    /**
     * Indicates if the method tests contain success.
     *
     * @return true if the method tests contain success, false otherwise.
     */
    public boolean hasMethodSuccess()
    {
        return !successList.isEmpty();
    }
}
